package com.hospital.user.registration.controller;

import com.hospital.user.registration.entity.Doctor_Info;
import com.hospital.user.registration.service.DoctorInfoServicei;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class DoctorController {

    @Autowired
    private DoctorInfoServicei servicei;

    @RequestMapping("/doc")
    public String findDoc() {
        return "/Userr/registration/doctorInfo";
    }

    @RequestMapping("/userName")
    public String findByName(String name, HttpServletRequest req) {
        System.out.println(name);
        Doctor_Info doctor = servicei.FindByNames(name);
        req.setAttribute("doctor", doctor);
        return "Userr/registration/doctorInfo";
    }

    @RequestMapping("/type")
    public String findByType(String opr, Model model) {
        System.out.println(opr);
        if (opr.equals("huazi")) {
            opr = "华子科";
        } else {
            opr = "骨科";
        }
        List<Doctor_Info> list = servicei.loockInfo(opr);
        model.addAttribute("list", list);
        return "/Userr/registration/subscribeInfo";
    }


}
